<?php
/**
 * Created by PhpStorm.
 * User: hoter.zhang
 * Date: 2016/9/2
 * Time: 15:45
 */

namespace app\modules\admin\controllers;


use app\modules\admin\models\WebConfig;

class ConfigController extends AdminBaseController
{

//    public function behaviors()
//    {
//        return [
//            'verbs' => [
//                'class' => VerbFilter::className(),
//                'actions' => [
//                    'delete' => ['POST'],
//                ],
//            ],
//            'access' => [
//                'class' => AccessControl::className(),
//                'rules' => [
//                    [
//                        'actions' => ['index', 'view', 'create', 'update', 'delete'],
//                        'allow' => true,
//                        'roles' => ['@'],
//                    ],
//                ],
//            ],
//        ];
//    }

    public function actionWeb(){
        $this->setForward();
        $model = new WebConfig();
        if ($model->load(\Yii::$app->request->post())) {
            if ($model->save()){
                $this->success('操作成功', $this->getForward(), true);
            } else {
                $msg = '';
                foreach ($model->getFirstErrors() as $v) {
                    $msg .= $v;
                }
                $this->error($msg,'#',true);
            }

        }
        $model->initValue();
        return $this->render('web', [
            'model' => $model
        ]);
    }

}